
package com.be.beadmin.service.repository;

import com.be.beadmin.service.entity.SerialNumber;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;

/**
* @author chenwei
* @date 2023-01-16
**/
public interface SerialNumberRepository extends JpaRepository<SerialNumber, String>, JpaSpecificationExecutor<SerialNumber> {

    SerialNumber findSerialNumberByIdAndDelete(String id, Integer delete);

    SerialNumber findSerialNumberById(String id);


    SerialNumber findSerialNumberByCodeAndDelete(String code, Integer isDelete);

    @Transactional
    @Modifying
    @Query(value = "update t_serial_number sn set sn.is_delete = 1 where sn.code like ?1",nativeQuery = true)
    int deleteSerialNumberByCode(String code);
}